package LeetcodeTest_four;
//仅反转字母
public class reverseOnlyLetters
{
    public static void main(String[] args)
    {
        String result=Solution.reverseOnlyLetters("Test1ng-Leet=code-Q!");
        System.out.println(result);
    }
}
class Solution
{
    public static String reverseOnlyLetters(String S)
    {
        char []a=S.toCharArray();
        int low,high;
        low=0;
        high=S.length()-1;
        char ch;
        while(low<=high)
        {
            if(Character.isLetter(a[low]))
            {
                if(Character.isLetter(a[high]))
                {
                    ch = a[low];
                    a[low]=a[high];
                    a[high]=ch;
                    low++;
                    high--;
                }
                else
                    high--;
            }
            else
                low++;
        }
        S=String.valueOf(a);
        return S;
    }
}
